home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / gui / gtlayout.lha / Source / LTP_BackFillRoutine.c < prev    next >
C/C++ Source or Header  |  1998-09-09  |  5KB  |  212 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16.     // Layer backfill hook support
  17.  
  18. struct LayerMsg
  19. {
  20.     struct Layer *        Layer;
  21.     struct Rectangle    Bounds;
  22. };
  23.  
  24.  
  25. VOID SAVE_DS ASM
  26. LTP_BackfillRoutine(
  27.     REG(a0) struct Hook *        Hook,
  28.     REG(a1) struct LayerMsg *    Bounds,
  29.     REG(a2) struct RastPort *    RPort)
  30. {
  31.     LayoutHandle *Handle = (LayoutHandle *)Hook->h_Data;
  32.  
  33.         // Make a copy of the rastport
  34.  
  35.     Handle->BackfillRastPort = *RPort;
  36.  
  37.         // Zap the layer pointer, we have to do this
  38.  
  39.     Handle->BackfillRastPort.Layer = NULL;
  40.  
  41.         // Now for the colours and drawing mode
  42.  
  43.     LTP_SetPens(&Handle->BackfillRastPort,Handle->BackgroundPen,0,JAM2);
  44.  
  45.         // Clear the area
  46.  
  47.     RectFill(&Handle->BackfillRastPort,
  48.         Bounds->Bounds.MinX,Bounds->Bounds.MinY,
  49.         Bounds->Bounds.MaxX,Bounds->Bounds.MaxY);
  50. }
  51.  
  52. /*
  53. VOID SAVE_DS ASM
  54. LTP_BackfillRoutine(REG(a0) struct Hook *Hook,REG(a1) struct LayerMsg *Bounds,REG(a2) struct RastPort *RPort)
  55. {
  56.     STATIC UWORD __chip EscherData[216] =
  57.     {
  58.         0xFFF0,0xFFE7,0xF703,0xFF00,0xFFFF,0xFFF9,0xF801,0xFF00,
  59.         0xFFFF,0xFFFE,0xF000,0xFF00,0xFFFF,0xFCFF,0x6000,0x7F00,
  60.         0xFFFF,0xFF3F,0x8020,0x7F00,0xFFFF,0xFFCF,0xC000,0x9F00,
  61.         0xFFFF,0xFFF7,0x8001,0x0700,0xFFFF,0xFFFB,0x8001,0x0100,
  62.         0xFFFF,0xFFFD,0x0001,0x0000,0xFFFF,0xFFFE,0x007F,0xFF00,
  63.         0xFFFF,0xFFFF,0x00FF,0xFF00,0xFFFF,0xFFFF,0x00FF,0xFF00,
  64.         0xFE7F,0xFFFF,0x00FF,0xFF00,0x7F9F,0xFFFF,0x807F,0xFE00,
  65.         0x9FEF,0xFFFF,0x807F,0xFF00,0xE7F7,0xFFFF,0x803F,0x9F00,
  66.         0xFBF8,0x07FF,0xA00F,0xE700,0xFDE0,0x007F,0xB007,0xF900,
  67.         0xFEC0,0x009F,0xB801,0xFE00,0x7F00,0x0067,0xBC00,0xFF00,
  68.         0xBE00,0x0079,0x9E00,0x3F00,0xD800,0x003C,0x6F00,0x1F00,
  69.         0xE000,0x003D,0xF700,0x0F00,0xE006,0x001E,0xF700,0x0700,
  70.         0xC018,0x001E,0xFA00,0x0700,0x8020,0x000F,0x7000,0x0300,
  71.         0x0040,0x600F,0x0000,0x0300,0x0081,0x8000,0x0000,0x0200,
  72.         0xF902,0x0000,0x0000,0x0100,0xFF04,0x0000,0x0000,0x0700,
  73.         0xFF88,0x0C00,0x0000,0x0F00,0xBFD0,0x3000,0x0000,0x1F00,
  74.         0xFFE0,0xC000,0x0000,0x6F00,0xFFE1,0x0000,0x0001,0xF700,
  75.         0xFFE2,0x0000,0x0007,0xF700,0x1FE4,0x0000,0x0000,0x0000,
  76.         0x0FE8,0x0000,0x0000,0x0000,0x0FF0,0x0000,0x0000,0x0000,
  77.         0x0FE0,0x0000,0x0000,0x0000,0x1FE0,0x0000,0x0000,0x0000,
  78.         0x3FE0,0x0000,0x3030,0x0000,0x7FA0,0x0000,0xC0C0,0xC000,
  79.         0xFFA0,0x0001,0x0103,0x0000,0xFF20,0x0002,0x0204,0x0300,
  80.         0xFE20,0x1FFC,0x0408,0x0F00,0xFC20,0x63FF,0x8810,0x1F00,
  81.         0xF821,0x87FF,0xF020,0x3F00,0xF066,0x0FFF,0xF840,0x7F00,
  82.         0xE09C,0x1FFF,0xFC40,0xFF00,0xE104,0x1FFF,0xFE81,0xFF00,
  83.         0xE108,0x3FF9,0xFF81,0xFF00,0xF208,0x3FFE,0x7FC3,0xFF00,
  84.         0xFA10,0x7FFF,0x9FE3,0xFF00,0xFF10,0x7F9F,0xEFF3,0xFF00
  85.     };
  86.  
  87.     struct RastPort RastPort;
  88.  
  89.     LayoutHandle *Handle = (LayoutHandle *)Hook->h_Data;
  90.  
  91.     LONG    PatternWidth,
  92.             PatternHeight;
  93.  
  94.     LONG    FromMinX,FromMinY,FromMaxX,FromMaxY,
  95.             SaveMinX,SaveMaxX,SaveToMinX,
  96.             ToMinX,ToMinY;
  97.     LONG    Width,Height;
  98.     LONG    Offset;
  99.     LONG    Modulo;
  100.  
  101.     InitRastPort(&RastPort);
  102.     RastPort.BitMap = RPort->BitMap;
  103.     SetABPenDrMd(&RastPort,Handle->DrawInfo->dri_Pens[FILLPEN],Handle->DrawInfo->dri_Pens[BACKGROUNDPEN],JAM2);
  104.  
  105.     Modulo = ((56 + 15) >> 4) * 2;
  106.  
  107.         // Pick up the initial data
  108.  
  109.     PatternWidth    = 56;
  110.     PatternHeight    = 54;
  111.  
  112.     ToMinX            = Bounds->Bounds.MinX;
  113.     ToMinY            = Bounds->Bounds.MinY;
  114.  
  115.     FromMinX        = Bounds->Bounds.MinX;
  116.     FromMinY        = Bounds->Bounds.MinY;
  117.  
  118.     FromMaxX        = Bounds->Bounds.MaxX;
  119.     FromMaxY        = Bounds->Bounds.MaxY;
  120.  
  121.         // NOTEZ-BIEN: the following layer offset adjustments are for
  122.         //             window layer backfill only, for screen layer
  123.         //             backfills the Layer pointer would be invalid.
  124.  
  125.         // Adjust for window left edge
  126.  
  127.     if(Offset = Bounds->Layer->bounds.MinX % PatternWidth)
  128.     {
  129.         FromMinX += Offset;
  130.         FromMaxX += Offset;
  131.     }
  132.  
  133.         // Adjust for window top edge
  134.  
  135.     if(Offset = Bounds->Layer->bounds.MinY % PatternHeight)
  136.     {
  137.         FromMinY += Offset;
  138.         FromMaxY += Offset;
  139.     }
  140.  
  141.         // Save these for later
  142.  
  143.     SaveMinX    = FromMinX;
  144.     SaveMaxX    = FromMaxX;
  145.     SaveToMinX    = ToMinX;
  146.  
  147.     do
  148.     {
  149.         do
  150.         {
  151.                 // Unwrap the left edge
  152.  
  153.             if(PatternWidth <= FromMinX)
  154.             {
  155.                 LONG OldMinX = FromMinX;
  156.  
  157.                 FromMinX %= PatternWidth;
  158.                 FromMaxX -= (OldMinX - FromMinX);
  159.             }
  160.  
  161.                 // Unwrap the top edge
  162.  
  163.             if(PatternHeight <= FromMinY)
  164.             {
  165.                 LONG OldMinY = FromMinY;
  166.  
  167.                 FromMinY %= PatternHeight;
  168.                 FromMaxY -= (OldMinY - FromMinY);
  169.             }
  170.  
  171.                 // Stay within horizontal bounds
  172.  
  173.             if((Width = FromMaxX) >= PatternWidth)
  174.                 Width = PatternWidth - 1;
  175.  
  176.             Width = Width - FromMinX + 1;
  177.  
  178.                 // Stay within vertical bounds
  179.  
  180.             if((Height = FromMaxY) >= PatternHeight)
  181.                 Height = PatternHeight - 1;
  182.  
  183.             Height = Height - FromMinY + 1;
  184.  
  185.                 // Blast in the image
  186.  
  187.             BltTemplate(&((PLANEPTR)EscherData)[FromMinY * Modulo + ((FromMinX & ~0xF) / 8)],FromMinX & 0xF,Modulo,&RastPort,ToMinX,ToMinY,Width,Height);
  188.  
  189.                 // Move up to next column
  190.  
  191.             FromMinX    += Width;
  192.             ToMinX         += Width;
  193.         }
  194.         while(FromMaxX >= FromMinX);
  195.  
  196.             // Return to first column
  197.  
  198.         FromMinX    = SaveMinX;
  199.         FromMaxX    = SaveMaxX;
  200.         ToMinX        = SaveToMinX;
  201.  
  202.             // Move up to next row
  203.  
  204.         Height = PatternHeight - 1 - FromMinY + 1;
  205.  
  206.         FromMinY    += Height;
  207.         ToMinY        += Height;
  208.     }
  209.     while(FromMaxY >= PatternHeight);
  210. }
  211. */
  212.